package org.baojie.parser;

import org.baojie.ParserState;
import org.baojie.SourceDetail;

/**
 * @author baojie
 * @date 2022/6/14 下午4:35
 */
public class SQLParser extends BaojieParser {

    private SQLParser() {

    }

    private static volatile SQLParser instance;

    public static final SQLParser getInstance() {
        if (null == instance) {
            synchronized (SQLParser.class) {
                if (null == instance) {
                    instance = new SQLParser();
                }
            }
        }
        return instance;
    }

    // 读入的语句需要先去除--或者#或者/* */的语句注释
    // 否则会解析错误
    @Override
    public final ParserState parser(String sqls, SourceDetail detail) {
        if (null == sqls || null == detail) {
            throw new IllegalArgumentException("null arguments");
        }
        final ParserState result = parser0(sqls, detail);
        return result;
    }

}
